package com.wqh.feign.service;

import com.wqh.feign.domain.User;
import com.wqh.feign.service.fallback.UserServiceFallback;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author wanqh
 * @date 2018/01/16 9:48
 * @description:
 */
@FeignClient(value = "USER-SERVICE",fallback= UserServiceFallback.class)
public interface UserService {

    @GetMapping("/feign/user/list")
    List<User> findAll();


    /**
     * 根据id查询用户，将参数包含在Request参数
     */
    @GetMapping("/feign/userById")
    User finUserById(@RequestParam("id") Long id);

    /**
     * 带有Header信息的请求
     */
    @GetMapping("/feign/header/user")
    User findUserHeader(@RequestHeader("name") String name, @RequestHeader("id") Long id,@RequestHeader("age") Integer age);

    /**
     * 带有RequestBody以及请求相应体是一个对象的请求
     */
    @PostMapping("/feign/insert")
    User insertUser(@RequestBody User user);
}
